package com.aaa.gs.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration  //相当于spring-config.xml  applicationContext.xml
public class MyCustomRule {

    /**
     * 初始化负载均衡策略
     * @return
     */
    @Bean
//    @LoadBalanced  //负载均衡注解
    public IRule iRule(){
        //七种负载均衡规则  选择随机算法
//        return new RandomRule();
        return new RoundRobinRule();
    }
}
